<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let str = '  hello world  '

    console.log(str);
    console.log(str.trimStart());   // hello world        后面的空格去不掉
    console.log(str.trimEnd());     //  hello world     前面的空格去不掉

    console.log(str.trim());    // 两边的都去掉


  </script>
</body>

</html>